#include <stdio.h>
#include "../../liboctopus/src/octopus.h"


#define PWMPIN 30
#define ADPIN 17

int
main ()
{

  struct octopus_context octopus;
  int ad_temperatur, pwm_wert;

  octopus_init (&octopus);
  octopus_open (&octopus);
  octopus_pwm_init (&octopus, PWMPIN);
  octopus_pwm_speed (&octopus, PWMPIN, 1);

  octopus_adc_init (&octopus, ADPIN);

  for(i=0;i<60;i++)
  {
    ad_temperatur = octopus_adc_get (&octopus, ADPIN);
    if(ad_temperatur < 100) pwm_wert = 10;
    else if(ad_temperatur < 200) pwm_wert = 30;
    else if(ad_temperatur < 300) pwm_wert = 60;
    else if(ad_temperatur < 400) pwm_wert = 80;
    else if(ad_temperatur < 600) pwm_wert = 100;
    else if(ad_temperatur < 800) pwm_wert = 150;
    else if(ad_temperatur > 1000) pwm_wert = 255;
    else pwm_wert = 0;

    octopus_pwm_value (&octopus, PWMPIN, (unsigned char)pwm_wert);
    sleep(1000);
  }
  
  
  octopus_pwm_value (&octopus, PWMPIN, 1);
  octopus_pwm_deinit (&octopus, PWMPIN);
  octopus_close (&octopus);



  return 0;


}
  
